home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
wtjmarch.zip
/
HATCH.ZIP
/
KPWIN.TXT
< prev
next >
Wrap
Text File
|
1992-02-21
|
1KB
|
47 lines
FIGURE 2: KnowledgePro (Windows) example of Inheritance
topic Item.
(* Inventory class for stationery store. *)
:price is getPrice().
:supplier is getSupplier().
:onHand is getOnHand().
topic getPrice.
(* Apply default 40% markup. *)
ask ('What is our cost?', cost).
getPrice is ?cost + (.40 * ?cost).
end.
topic getSupplier.
getSupplier is 'East End Wholesale'.
end.
topic getOnHand.
ask ('How many are on hand?', getOnHand).
end.
end.
topic PenItem.
(* PenItem is a subclass of Item. *)
im_a (Item).
topic getPrice.
(* PenItem's unique getPrice method. *)
ask('What is our cost?', cost).
getPrice is ?cost + (.50 * ?cost).
end.
end. (* PenItem *)
topic PaperItem.
(* PaperItem is a subclass of Item. *)
im_a (Item).
topic getSupplier
getSupplier is 'Paper World'.
end.
end. (* PaperItem *)
topic GiftItem
(* GiftItem is a subclass of Item. *)
im_a (Item).
end. (* GiftItem *)